package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/user/hosp/schedule")
public class UserScheduleController {


    @Autowired
    private ScheduleService scheduleService;


    @GetMapping("/{hoscode}/{depcode}/{pageNum}/{pageSize}")
    public R getSchedulePage(@PathVariable String hoscode,
                             @PathVariable String depcode,
                             @PathVariable Integer pageNum,
                             @PathVariable Integer pageSize) {

        Map<String, Object> map = scheduleService.getBookingScheduleRule(hoscode, depcode, pageNum, pageSize);
        return R.ok().data(map);
    }

    @GetMapping("/detail/{hoscode}/{depcode}/{date}")
    public R getScheduleDetail(@PathVariable String hoscode,
                               @PathVariable String depcode,
                               @PathVariable String date) {
        List<Schedule> schedules = scheduleService.getScheduleDetail(hoscode, depcode, date);
        return R.ok().data("details", schedules);
    }

    @GetMapping("/getSchedule/{scheduleId}")
    public R getSchedule(@PathVariable String scheduleId) {
        Schedule schedule = scheduleService.getSchedule(scheduleId);
        return R.ok().data("schedule", schedule);
    }



    @GetMapping("/{scheduleId}")
    public ScheduleOrderVo getScheduleById(@PathVariable String scheduleId) {
        return scheduleService.getScheduleById(scheduleId);
    }
}
